import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 东莞呵呵
 * Date:2022-03-24
 * Time:14:13
 */

/**
 * 一次：A->C
 * 两次：A->B A->C B->C
 * 三次: A->C, A->B, C->B, A->C, B->A, B->C, A->C
 */

public class TestDemo {

    public static void move(char a,char b){
        System.out.print(a+"->"+b+" ");
    }

    /**
     * a是存放汉诺塔的柱子
     * b是中转的柱子
     * c是最终的柱子
     */
    public  static  void Hanoi(int n,char a,char b,char c){
        if(n==1){
            move(a,c);
        }
        else{
            Hanoi(n-1,a,c,b);
            move(a,c);
            Hanoi(n-1,b,a,c);
        }
    }

    public static void main(String[] args) {
        int n=0;
        Scanner scanner=new Scanner(System.in);
        n = scanner.nextInt();
        Hanoi(n,'A','B','C');
    }
}
